import { ref, reactive } from "vue";
import { getDataList } from "@/api/uploadMap";
export function useGoodsExamine() {
  const pagination = reactive({
    total: 10,
    pageSize: 10,
    currentPage: 2
  });
  const tableData = ref<any>([]);
  const columns = reactive([
    { prop: "number", label: "地图编号" },
    { prop: "name", label: "地图名称" },
    { prop: "file", label: "地图文件" },
    { prop: "coordinate", label: "地图坐标" },
    { prop: "information", label: "指北信息" },
    { prop: "visualAngle", label: "初始视角" },
    { prop: "int", label: "标记数量" },
    { prop: "updateUser", label: "修改账号" }
    // { prop: "updateTime", label: "修改时间" }
  ]);
  const getData = parms => {
    getDataList(parms).then(res => {
      const { code, data } = res;
      if (code === 200) {
        const { list, total } = data;
        tableData.value = list || [];
        pagination.total = total || 0;
      }
    });
  };
  const getTime = time => {
    const date = new Date(time);
    const year = date.getFullYear();
    const month = (date.getMonth() + 1).toString().padStart(2, "0");
    const day = date.getDate().toString().padStart(2, "0");
    return `${year}-${month}-${day}`;
  };
  return { columns, pagination, getTime, getData, tableData };
}
